package com.ruoyi.web.controller.billSettings;


import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ServiceFeeSettings;
import com.ruoyi.system.service.IServiceFeeSettingsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 服务费设置 Controller
 *
 * @author ruoyi
 * @date 2025-05-09
 */
@Api(tags="服务费设置")
@RestController
@RequestMapping("/system/serviceFeeSettings")
public class ServiceFeeSettingsController extends BaseController
{
    @Autowired
    private IServiceFeeSettingsService serviceFeeSettingsService;

    /**
     * 通过id查询服务费设置列表
     */
    @ApiOperation("通过id查询服务费设置列表")
    @PreAuthorize("@ss.hasPermi('system:settings:list')")
    @GetMapping("/list")
    public TableDataInfo list(@RequestParam(required = false) String storeName)
    {
        startPage();
        List<ServiceFeeSettings> list = serviceFeeSettingsService.selectServiceFeeSettingsListByName(storeName);
        return getDataTable(list);
    }

    /**
     * 导出服务费设置列表
     */
    @ApiOperation("导出服务费设置列表")
    @PreAuthorize("@ss.hasPermi('system:settings:export')")
    @Log(title = "服务费设置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, @RequestParam(required = false) String storeName)
    {
        List<ServiceFeeSettings> list = serviceFeeSettingsService.selectServiceFeeSettingsListByName(storeName);
        ExcelUtil<ServiceFeeSettings> util = new ExcelUtil<ServiceFeeSettings>(ServiceFeeSettings.class);
        util.exportExcel(response, list, "服务费设置数据");
    }

    /**
     * 通过id获取服务费设置详细信息
     */
    @ApiOperation("通过id获取服务费设置详细信息")
    @PreAuthorize("@ss.hasPermi('system:settings:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(serviceFeeSettingsService.selectServiceFeeSettingsById(id));
    }

    /**
     * 新增服务费设置
     */
    @ApiOperation("新增服务费设置")
    @PreAuthorize("@ss.hasPermi('system:settings:add')")
    @Log(title = "服务费设置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ServiceFeeSettings serviceFeeSettings)
    {
        return toAjax(serviceFeeSettingsService.insertServiceFeeSettings(serviceFeeSettings));
    }

    /**
     * 修改服务费设置
     */
    @ApiOperation("修改服务费设置")
    @PreAuthorize("@ss.hasPermi('system:settings:edit')")
    @Log(title = "服务费设置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ServiceFeeSettings serviceFeeSettings)
    {
        return toAjax(serviceFeeSettingsService.updateServiceFeeSettings(serviceFeeSettings));
    }

    /**
     * 通过id批量删除服务费设置信息
     */
    @ApiOperation("通过id批量删除服务费设置信息")
    @PreAuthorize("@ss.hasPermi('system:settings:remove')")
    @Log(title = "服务费设置", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(serviceFeeSettingsService.deleteServiceFeeSettingsByIds(ids));
    }
}

